﻿// Kevin Dockx, 11/2009 

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel;

namespace WhatTheHelp.Core.Client.Repository
{
    public class XMLRepository : IWhatTheHelpRepository
    {

        #region IWhatTheHelpRepository Members

        public void RetrieveHelp(HelpOverlayCriteria helpOverlayCriteria)
        {
            // TODO: service location moet vanuit config file / parameter class komen 
            // TODO: binary bindings

            BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
            EndpointAddress endpointAddress =
                new EndpointAddress("http://localhost:1849/XMLRepositoryService.svc");
            IRepositoryServiceClient xmlService =
                new ChannelFactory<IRepositoryServiceClient>(basicHttpBinding, endpointAddress).CreateChannel();


            var y = xmlService.BeginRetrieveHelp(new HelpOverlayCriteria()
                , (asyncResult) =>
                {
                    
                    // TODO : errorchecking, parse helpOverlays to local datastore

                    LocalDataStore.AddHelpOverlays(xmlService.EndRetrieveHelp(asyncResult));
                   
                }
                , null);
        }

        public void StoreHelp(HelpOverlay helpOverlay)
        {
            // TODO
        }

        #endregion
    }
}
